package com.example.once.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.once.entity.Record;
import com.example.once.entity.RecordVO;
import com.example.once.mapper.RecordMapper;
import com.example.once.common.PageQuery;
import com.example.once.service.RecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xinTong
 * @since 2023-12-16
 */
@Service
public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements RecordService {

    @Autowired
    private RecordMapper recordMapper;

    @Override
    public Page<RecordVO> pageQuery(PageQuery query) {

        HashMap param = query.getParam();
        String name = (String) param.get("name");
        List<RecordVO> list = recordMapper.pageQuery();

        IPage<RecordVO> page = new Page<>(query.getPageNum(), query.getPageSize());

        page.setRecords(list);
        //System.out.println("总页数： " + page.getPages());
        System.out.println("总记录数： " + list.size());

        return (Page<RecordVO>) page;
    }
}
